package org.javaforever.gatescore.core;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.javaforever.gatescore.exception.ValidateException;
import org.javaforever.gatescore.utils.StringUtil;
import org.javaforever.gatescore.verb.SearchByFieldsByPage;

public class UtilsMethodGenerator {
	public static StatementList generateBuildParamsStatements(FrontDomain domain, FrontVar listQuery,FrontVar postForm) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"buildParams("+listQuery.getVarName()+", "+postForm.getVarName()+") {"));
		sList.add(new Statement(2000L,3,"return {"));
		sList.add(new Statement(3000L,4,"page: "+listQuery.getVarName()+".page,"));
		sList.add(new Statement(4000L,4,"rows: "+listQuery.getVarName()+".rows,"));
		long serial = 5000L;
		for (FrontField f:domain.getAllFieldsWithoutId()) {
			sList.add(new Statement(serial,4,f.getFieldName()+": "+postForm.getVarName()+"."+f.getFieldName()+","));
			serial += 1000L;
		}
		sList.add(new Statement(serial,4,"token: getToken()"));
		sList.add(new Statement(serial+1000L,3,"}"));
		sList.add(new Statement(serial+2000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateBuildParamsStatementsWithDeniedFields(FrontDomain domain, FrontVar listQuery,FrontVar postForm,Set<FrontField> deniedFields) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"buildParams("+listQuery.getVarName()+", "+postForm.getVarName()+") {"));
		sList.add(new Statement(2000L,1,"return {"));
		sList.add(new Statement(3000L,2,"page: "+listQuery.getVarName()+".page,"));
		sList.add(new Statement(4000L,2,"rows: "+listQuery.getVarName()+".rows,"));
		long serial = 5000L;
		for (FrontField f:domain.getAllFieldsWithoutId()) {
			if (!deniedFields.contains(f)) {
				sList.add(new Statement(serial,2,f.getFieldName()+": "+postForm.getVarName()+"."+f.getFieldName()+","));
				serial += 1000L;
			}
		}
		sList.add(new Statement(serial,2,"token: getToken(),"));
		sList.add(new Statement(serial+1000L,1,"}"));
		sList.add(new Statement(serial+2000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateBuildParamsStatements(FrontDomain domain, FrontVar listQuery,FrontVar postForm,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"buildParams"+indexSuffix+"("+listQuery.getVarName()+", "+postForm.getVarName()+") {"));
		sList.add(new Statement(2000L,1,"return {"));
		sList.add(new Statement(3000L,2,"page: "+listQuery.getVarName()+".page,"));
		sList.add(new Statement(4000L,2,"rows: "+listQuery.getVarName()+".rows,"));
		long serial = 5000L;
		for (FrontField f:domain.getAllFieldsWithoutId()) {
			sList.add(new Statement(serial,2,f.getFieldName()+": "+postForm.getVarName()+"."+f.getFieldName()+","));
			serial += 1000L;
		}
		sList.add(new Statement(serial,2,"token: getToken(),"));
		sList.add(new Statement(serial+1000L,1,"}"));
		sList.add(new Statement(serial+2000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateBuildIdsStatements(FrontDomain domain, FrontVar data) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"buildIds("+data.getVarName()+") {"));
		sList.add(new Statement(2000L,3,"var retVal = ''"));
		sList.add(new Statement(3000L,3,"for (var i = 0; i < "+data.getVarName()+".length; i++) {"));
		sList.add(new Statement(4000L,4,"retVal += "+data.getVarName()+"[i]."+domain.getDomainId().getFieldName()+" + ','"));
		sList.add(new Statement(5000L,3,"}"));
		sList.add(new Statement(6000L,3,"if (retVal.indexOf(',') >= 0) retVal = retVal.substring(0, retVal.length - 1)"));
		sList.add(new Statement(7000L,3,"return retVal"));
		sList.add(new Statement(8000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateBuildIdsStatements(FrontDomain domain, FrontVar data, String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"buildIds"+indexSuffix+"("+data.getVarName()+") {"));
		sList.add(new Statement(2000L,1,"var retVal = ''"));
		sList.add(new Statement(3000L,1,"for (var i = 0; i < "+data.getVarName()+".length; i++) {"));
		sList.add(new Statement(4000L,2,"retVal += "+data.getVarName()+"[i]."+domain.getDomainId().getFieldName()+" + ','"));
		sList.add(new Statement(5000L,1,"}"));
		sList.add(new Statement(6000L,1,"if (retVal.indexOf(',') >= 0) retVal = retVal.substring(0, retVal.length - 1)"));
		sList.add(new Statement(7000L,1,"return retVal"));
		sList.add(new Statement(8000L,0,"},"));
		return WriteableUtil.merge(sList);
	}

	public static StatementList generateDataBlockStatements(FrontDomain domain, FrontVar listQuery,FrontVar postForm, FrontVar defaultForm, FrontVar pagevars,Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,1,"data() {"));
		sList.add(new Statement(2000L,2,"return {"));
		sList.add(new Statement(3000L,3,postForm.getVarName()+": Object.assign({}, "+defaultForm.getVarName()+"),"));
		sList.add(new Statement(4000L,3,"list: [],"));
		sList.add(new Statement(5000L,3,"selectList: [],"));
		sList.add(new Statement(6000L,3,"selectRows: [],"));
		sList.add(new Statement(7000L,3,"total: 0,"));
		sList.add(new Statement(8000L,3,"listLoading: true,"));
		sList.add(new Statement(9000L,3,"cellValue: null,"));
		sList.add(new Statement(10000L,3,"addDialogVisible: false,"));
		sList.add(new Statement(11000L,3,"editDialogVisible: false,"));
		sList.add(new Statement(12000L,3,"viewDialogVisible: false,"));
		long serial = 14000L;
		for (FrontField f: domain.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,3, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,3, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		sList.add(new Statement(serial,3,"baseApi: process.env.BASE_API,"));
		sList.add(new Statement(serial+1000L,3,"token: { Authorization: getToken(), 'X-Token': getToken() },"));
		sList.add(new Statement(serial+2000L,3,"form: {},"));
		serial += 3000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,3,"active"+d.getCapFirstPlural()+": {},"));
			sList.add(new Statement(serial+1000L,3,"init"+d.getCapFirstDomainName()+"Store: "+pagevars.getVarName()+".init"+d.getCapFirstDomainName()+"Store,"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,3,listQuery.getVarName()+": {"));
		sList.add(new Statement(serial+1000L,4,"page: 1,"));
		sList.add(new Statement(serial+2000L,4,"rows: 10"));
		sList.add(new Statement(serial+3000L,3,"}"));
		sList.add(new Statement(serial+4000L,2,"}"));
		sList.add(new Statement(serial+5000L,1,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDualDataBlockStatements(FrontDomain domain, FrontVar listQuery,FrontVar postForm, FrontVar defaultForm, FrontVar pagevars,Set<FrontDomain> dpDomains,
			FrontDomain domain2, FrontVar listQuery2,FrontVar postForm2, FrontVar defaultForm2, String indexSuffix2) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"data() {"));
		sList.add(new Statement(2000L,1,"return {"));
		sList.add(new Statement(3000L,2,postForm.getVarName()+": Object.assign({}, "+defaultForm.getVarName()+"),"));
		sList.add(new Statement(4000L,2,"list: [],"));
		sList.add(new Statement(5000L,2,"selectList: [],"));
		sList.add(new Statement(6000L,2,"selectRows: [],"));
		sList.add(new Statement(7000L,2,"total: 0,"));
		sList.add(new Statement(8000L,2,"listLoading: true,"));
		sList.add(new Statement(9000L,2,"cellValue: null,"));
		sList.add(new Statement(10000L,2,"addDialogVisible: false,"));
		sList.add(new Statement(11000L,2,"editDialogVisible: false,"));
		sList.add(new Statement(12000L,2,"viewDialogVisible: false,"));		
		sList.add(new Statement(12300L,2,postForm2.getVarName()+": Object.assign({}, "+defaultForm2.getVarName()+"),"));
		sList.add(new Statement(12400L,2,"list"+indexSuffix2+": [],"));
		sList.add(new Statement(12500L,2,"selectList"+indexSuffix2+": [],"));
		sList.add(new Statement(12600L,2,"selectRows"+indexSuffix2+": [],"));
		sList.add(new Statement(12700L,2,"total"+indexSuffix2+": 0,"));
		sList.add(new Statement(12800L,2,"listLoading"+indexSuffix2+": true,"));
		sList.add(new Statement(12810L,2,"addDialogVisible"+indexSuffix2+": false,"));
		sList.add(new Statement(12820L,2,"editDialogVisible"+indexSuffix2+": false,"));
		sList.add(new Statement(12830L,2,"viewDialogVisible"+indexSuffix2+": false,"));
		
		long serial = 14000L;
		for (FrontField f: domain.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,2, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,2, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		for (FrontField f: domain2.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,2, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,2, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		sList.add(new Statement(serial,2,"baseApi: process.env.BASE_API,"));
		sList.add(new Statement(serial+1000L,2,"token: { Authorization: getToken(), 'X-Token': getToken() },"));
		sList.add(new Statement(serial+2000L,2,"form: {},"));
		sList.add(new Statement(serial+2000L,2,"form"+indexSuffix2+": {},"));
		serial += 3000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,2,"active"+d.getCapFirstPlural()+": {},"));
			sList.add(new Statement(serial+1000L,2,"init"+d.getCapFirstDomainName()+"Store: "+pagevars.getVarName()+".init"+d.getCapFirstDomainName()+"Store,"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,2,listQuery.getVarName()+": {"));
		sList.add(new Statement(serial+1000L,3,"page: 1,"));
		sList.add(new Statement(serial+2000L,3,"rows: 10"));
		sList.add(new Statement(serial+3000L,2,"},"));
		
		sList.add(new Statement(serial+5000L,2,listQuery2.getVarName()+": {"));
		sList.add(new Statement(serial+6000L,3,"page: 1,"));
		sList.add(new Statement(serial+7000L,3,"rows: 10"));
		sList.add(new Statement(serial+8000L,2,"}"));
		sList.add(new Statement(serial+9000L,1,"}"));
		sList.add(new Statement(serial+10000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	
	public static StatementList generateDataBlockWithChangePasswordDialogStatements(FrontDomain domain, FrontVar listQuery,FrontVar postForm, FrontVar defaultForm, FrontVar pagevars,Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"data() {"));
		sList.add(new Statement(2000L,1,"return {"));
		sList.add(new Statement(3000L,2,postForm.getVarName()+": Object.assign({}, "+defaultForm.getVarName()+"),"));
		sList.add(new Statement(4000L,2,"list: [],"));
		sList.add(new Statement(5000L,2,"selectList: [],"));
		sList.add(new Statement(6000L,2,"selectRows: [],"));
		sList.add(new Statement(7000L,2,"total: 0,"));
		sList.add(new Statement(8000L,2,"listLoading: true,"));
		sList.add(new Statement(9000L,2,"cellValue: null,"));
		sList.add(new Statement(10000L,2,"addDialogVisible: false,"));
		sList.add(new Statement(11000L,2,"editDialogVisible: false,"));
		sList.add(new Statement(12000L,2,"viewDialogVisible: false,"));
		sList.add(new Statement(13000L,2,"changePasswordDialogVisible: false,"));
		long serial = 14000L;
		for (FrontField f: domain.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,2, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,2, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		sList.add(new Statement(serial,2,"baseApi: process.env.BASE_API,"));
		sList.add(new Statement(serial+1000L,2,"token: { Authorization: getToken(), 'X-Token': getToken() },"));
		sList.add(new Statement(serial+2000L,2,"form: {},"));
		serial += 3000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,2,"active"+d.getCapFirstPlural()+": {},"));
			sList.add(new Statement(serial+1000L,2,"init"+d.getCapFirstDomainName()+"Store: "+pagevars.getVarName()+".init"+d.getCapFirstDomainName()+"Store,"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,2,listQuery.getVarName()+": {"));
		sList.add(new Statement(serial+1000L,3,"page: 1,"));
		sList.add(new Statement(serial+2000L,3,"rows: 10"));
		sList.add(new Statement(serial+3000L,2,"}"));
		sList.add(new Statement(serial+4000L,1,"}"));
		sList.add(new Statement(serial+5000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDataBlockStatementsForRegister(FrontDomain domain, FrontVar defaultForm, FrontVar pagevars, Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"data() {"));
		sList.add(new Statement(2000L,1,"return {"));
		long serial = 12000L;
		for (FrontField f: domain.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,2, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,2, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		sList.add(new Statement(serial,2,"loginBaseApi: process.env.LOGIN_BASE_API,"));
		sList.add(new Statement(serial+1000L,2,"form: "+defaultForm.getVarName()+","));
		serial += 2000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,2,"active"+d.getCapFirstPlural()+": {},"));
			sList.add(new Statement(serial+1000L,2,"init"+d.getCapFirstDomainName()+"Store: "+pagevars.getVarName()+".init"+d.getCapFirstDomainName()+"Store,"));
			serial += 2000L;
		}

		sList.add(new Statement(serial+4000L,1,"}"));
		sList.add(new Statement(serial+5000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDataBlockStatementsForProfile(FrontDomain domain, FrontVar defaultForm, FrontVar pagevars, Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"data() {"));
		sList.add(new Statement(2000L,1,"return {"));
		long serial = 12000L;
		for (FrontField f: domain.getFields()) {
			if (f.getFieldType()!=null&& f.getFieldType().getTypeName()!=null&&"image".equalsIgnoreCase(f.getFieldType().getTypeName())) {
				sList.add(new Statement(serial,2, f.getLowerFirstFieldName()+"ImageUrl: '',"));
				sList.add(new Statement(serial+1000L,2, f.getLowerFirstFieldName()+"File: '',"));
				serial += 2000L;
			}	
		}
		sList.add(new Statement(serial,2,"baseApi: process.env.BASE_API,"));
		sList.add(new Statement(serial+1000L,2,"token: { Authorization: getToken(), 'X-Token': getToken() },"));
		sList.add(new Statement(serial+2000L,2,"form: "+defaultForm.getVarName()+","));
		serial += 3000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,2,"active"+d.getCapFirstPlural()+": {},"));
			sList.add(new Statement(serial+1000L,2,"init"+d.getCapFirstDomainName()+"Store: "+pagevars.getVarName()+".init"+d.getCapFirstDomainName()+"Store,"));
			serial += 2000L;
		}
		sList.add(new Statement(serial+1000L,2,"changePasswordDialogVisible: false,"));
		sList.add(new Statement(serial+2000L,1,"}"));
		sList.add(new Statement(serial+3000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateCreatedBlockStatements(FrontDomain domain,Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,1,"created() {"));
		long serial = 2000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,2,"this.init"+d.getCapFirstDomainName()+"Store()"));
			sList.add(new Statement(serial+1000L,2,"this.listActive"+d.getCapFirstPlural()+"()"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,2,"this.search"+domain.getCapFirstPlural()+"ByFieldsByPage()"));
		sList.add(new Statement(serial+1000L,1,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateRegisterUserCreatedBlockStatements(Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"created() {"));
		long serial = 2000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,1,"this.init"+d.getCapFirstDomainName()+"Store()"));
			sList.add(new Statement(serial+1000L,1,"this.listActive"+d.getCapFirstPlural()+"()"));
			serial += 2000L;
		}
		sList.add(new Statement(serial+1000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateCreatedDualBlockStatements(FrontDomain domain,FrontDomain domain2,Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"created() {"));
		long serial = 2000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,1,"this.init"+d.getCapFirstDomainName()+"Store()"));
			sList.add(new Statement(serial+1000L,1,"this.listActive"+d.getCapFirstPlural()+"()"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,1,"this.search"+domain.getCapFirstPlural()+"ByFieldsByPage()"));
		sList.add(new Statement(serial+1000L,1,"this.search"+domain2.getCapFirstPlural()+"ByFieldsByPage()"));
		sList.add(new Statement(serial+2000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateCompareCreatedBlockStatements(FrontDomain planDomain,FrontDomain actionDomain,Set<FrontDomain> dpDomains) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"created() {"));
		long serial = 2000L;
		for (FrontDomain d: dpDomains) {
			sList.add(new Statement(serial,1,"this.init"+d.getCapFirstDomainName()+"Store()"));
			sList.add(new Statement(serial+1000L,1,"this.listActive"+d.getCapFirstPlural()+"()"));
			serial += 2000L;
		}
		sList.add(new Statement(serial,1,"this.search"+planDomain.getCapFirstPlural()+"ByFieldsByPage()"));
		sList.add(new Statement(serial+1000L,1,"this.search"+actionDomain.getCapFirstPlural()+"ByFieldsByPage()"));
		sList.add(new Statement(serial+2000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDefaultFormBlockStatements(FrontDomain domain,FrontVar defaultForm) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"const "+defaultForm.getVarName()+" = {"));
		long serial = 2000L;
		for (FrontField f:domain.getAllFieldsWithoutId()) {
			sList.add(new Statement(serial,1,f.getFieldName()+": '',"));
			serial += 1000L;
		}
		sList.add(new Statement(serial,0,"}"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDefaultFormBlockStatementsWithoutDeniedFields(FrontDomain domain,Set<FrontField> deniedFileds,FrontVar defaultForm) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"const "+defaultForm.getVarName()+" = {"));
		long serial = 2000L;
		for (FrontField f:domain.getAllFieldsWithoutId()) {
			if (!deniedFileds.contains(f)) {
				sList.add(new Statement(serial,1,f.getFieldName()+": '',"));
				serial += 1000L;
			}
		}
		sList.add(new Statement(serial,0,"}"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateDomainFilterStatements(FrontDomain domain, FrontVar pagevars) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,1,domain.getLowerFirstDomainName()+"Filter("+domain.getDomainId().getFieldName()+") {"));
		sList.add(new Statement(2000L,2,"while ("+pagevars.getVarName()+"."+domain.getLowerFirstDomainName()+"Store."+domain.getLowerFirstDomainName()+"Map == null) this.sleep(100)"));
		sList.add(new Statement(3000L,2,"return "+pagevars.getVarName()+"."+domain.getLowerFirstDomainName()+"Store."+domain.getLowerFirstDomainName()+"Map["+domain.getDomainId().getFieldName()+"]"));
		sList.add(new Statement(4000L,1,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateSleepMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"sleep(delay) {"));
		sList.add(new Statement(2000L,3,"var start = (new Date()).getTime()"));
		sList.add(new Statement(3000L,3,"while ((new Date()).getTime() - start < delay) {"));
		sList.add(new Statement(4000L,4,"continue"));
		sList.add(new Statement(5000L,3,"}"));
		sList.add(new Statement(6000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateConfirmDeleteMethodStatements(FrontDomain domain) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"confirmDelete() {"));
		sList.add(new Statement(2000L,3,"this.$confirm('确定要删除"+domain.getText()+"?', '删除警告', {"));
		sList.add(new Statement(3000L,4,"confirmButtonText: '确定',"));
		sList.add(new Statement(4000L,4,"cancelButtonText: '取消',"));
		sList.add(new Statement(5000L,4,"type: 'warning'"));
		sList.add(new Statement(6000L,3,"}).then(() => {"));
		sList.add(new Statement(7000L,4,"delete"+domain.getCapFirstDomainName()+"(this.selectList[0]."+domain.getDomainId().getLowerFirstFieldName()+").then(response => {"));
		sList.add(new Statement(8000L,5,"this.reload()"));
		sList.add(new Statement(9000L,4,"})"));
		sList.add(new Statement(10000L,3,"}).catch(() => {"));
		sList.add(new Statement(11000L,3,"})"));
		sList.add(new Statement(12000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateConfirmDeleteMethodStatements(FrontDomain domain,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"confirmDelete"+indexSuffix+"() {"));
		sList.add(new Statement(2000L,1,"this.$confirm('确定要删除"+domain.getText()+"?', '删除警告', {"));
		sList.add(new Statement(3000L,2,"confirmButtonText: '确定',"));
		sList.add(new Statement(4000L,2,"cancelButtonText: '取消',"));
		sList.add(new Statement(5000L,2,"type: 'warning'"));
		sList.add(new Statement(6000L,1,"}).then(() => {"));
		sList.add(new Statement(7000L,2,"delete"+domain.getCapFirstDomainName()+"(this.selectList"+indexSuffix+"[0]."+domain.getDomainId().getLowerFirstFieldName()+").then(response => {"));
		sList.add(new Statement(8000L,3,"this.reload()"));
		sList.add(new Statement(9000L,2,"})"));
		sList.add(new Statement(10000L,1,"}).catch(() => {"));
		sList.add(new Statement(11000L,1,"})"));
		sList.add(new Statement(12000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateConfirmDeleteAllMethodStatements(FrontDomain domain) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"confirmDeleteAll(data) {"));
		sList.add(new Statement(2000L,3,"this.$confirm('确定要批删除"+domain.getText()+"?', '批删除警告', {"));
		sList.add(new Statement(3000L,4,"confirmButtonText: '确定',"));
		sList.add(new Statement(4000L,4,"cancelButtonText: '取消',"));
		sList.add(new Statement(5000L,4,"type: 'warning'"));
		sList.add(new Statement(6000L,3,"}).then(() => {"));
		sList.add(new Statement(7000L,4,"deleteAll"+domain.getCapFirstPlural()+"(this.buildIds(data)).then(response => {"));
		sList.add(new Statement(8000L,5,"this.reload()"));
		sList.add(new Statement(9000L,4,"})"));
		sList.add(new Statement(10000L,3,"}).catch(() => {"));
		sList.add(new Statement(11000L,3,"})"));
		sList.add(new Statement(12000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateConfirmDeleteAllMethodStatements(FrontDomain domain,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"confirmDeleteAll"+indexSuffix+"(data) {"));
		sList.add(new Statement(2000L,1,"this.$confirm('确定要批删除"+domain.getText()+"?', '批删除警告', {"));
		sList.add(new Statement(3000L,2,"confirmButtonText: '确定',"));
		sList.add(new Statement(4000L,2,"cancelButtonText: '取消',"));
		sList.add(new Statement(5000L,2,"type: 'warning'"));
		sList.add(new Statement(6000L,1,"}).then(() => {"));
		sList.add(new Statement(7000L,2,"deleteAll"+domain.getCapFirstPlural()+"(this.buildIds"+indexSuffix+"(data)).then(response => {"));
		sList.add(new Statement(8000L,3,"this.reload()"));
		sList.add(new Statement(9000L,2,"})"));
		sList.add(new Statement(10000L,1,"}).catch(() => {"));
		sList.add(new Statement(11000L,1,"})"));
		sList.add(new Statement(12000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleSizeChangeMethodStatements(FrontVar listQuery) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handleSizeChange(val) {"));
		sList.add(new Statement(2000L,3,"this."+listQuery.getVarName()+".page = val"));
		sList.add(new Statement(3000L,3,"this.getList()"));
		sList.add(new Statement(4000L,2,"},"));
		return WriteableUtil.merge(sList);
	}	
	
	public static StatementList generateHandleSizeChangeMethodStatements(FrontVar listQuery,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"handleSizeChange"+indexSuffix+"(val) {"));
		sList.add(new Statement(2000L,1,"this."+listQuery.getVarName()+".page = val"));
		sList.add(new Statement(3000L,1,"this.getList"+indexSuffix+"()"));
		sList.add(new Statement(4000L,0,"},"));
		return WriteableUtil.merge(sList);
	}	
	
	public static StatementList generateHandleCurrentChangeMethodStatements(FrontVar listQuery) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handleCurrentChange(val) {"));
		sList.add(new Statement(2000L,3,"this."+listQuery.getVarName()+".rows = val"));
		sList.add(new Statement(3000L,3,"this.getList()"));
		sList.add(new Statement(4000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCurrentChangeMethodStatements(FrontVar listQuery,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"handleCurrentChange"+indexSuffix+"(val) {"));
		sList.add(new Statement(2000L,1,"this."+listQuery.getVarName()+".rows = val"));
		sList.add(new Statement(3000L,1,"this.getList"+indexSuffix+"()"));
		sList.add(new Statement(4000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCheckedMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handleChecked(data) {"));
		sList.add(new Statement(2000L,3,"this.selectList = data"));
		sList.add(new Statement(3000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCheckedWithChildSelectMethodStatements(FrontDomain parentDomain,FrontDomain childDomain,FrontField parentId,String childIndexSuffix) throws ValidateException{
		SearchByFieldsByPage search = new SearchByFieldsByPage(childDomain);
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(500L,1,"handleChecked(data) {"));
		sList.add(new Statement(1000L,2,"this.selectList = data"));
		sList.add(new Statement(2000L,2,"if (this.selectList.length > 0) {"));
		sList.add(new Statement(3000L,3,"this.postForm"+childIndexSuffix+"."+parentId.getLowerFirstFieldName()+" = this.selectList[0]."+parentDomain.getDomainId().getLowerFirstFieldName()));
		sList.add(new Statement(4000L,3,"this."+StringUtil.lowerFirst(search.getVerbName())+"()"));
		sList.add(new Statement(5000L,2,"} else {"));
		sList.add(new Statement(6000L,3,"this.postForm2."+parentId.getLowerFirstFieldName()+" = ''"));
		sList.add(new Statement(7000L,3,"this."+StringUtil.lowerFirst(search.getVerbName())+"()"));
		sList.add(new Statement(8000L,2,"}"));
		sList.add(new Statement(9000L,1,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCheckedMethodStatements(String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"handleChecked"+indexSuffix+"(data) {"));
		sList.add(new Statement(2000L,1,"this.selectList"+indexSuffix+" = data"));
		sList.add(new Statement(3000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCheckedAllMethodStatements(FrontDomain domain) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handleCheckedAll(data) {"));
		sList.add(new Statement(2000L,3,"this.selectList = data"));
		sList.add(new Statement(3000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCheckedAllMethodStatements(FrontDomain domain,String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"handleCheckedAll"+indexSuffix+"(data) {"));
		sList.add(new Statement(2000L,1,"this.selectList"+indexSuffix+" = data"));
		sList.add(new Statement(3000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateSelectedHighlightMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"selectedHighlight({"));
		sList.add(new Statement(2000L,3,"row,"));
		sList.add(new Statement(3000L,3,"rowIndex"));
		sList.add(new Statement(4000L,2,"}) {"));
		sList.add(new Statement(5000L,3,"if (this.selectRows.includes(rowIndex)) {"));
		sList.add(new Statement(6000L,4,"return {"));
		sList.add(new Statement(7000L,5,"'background-color': '#a1c3c0'"));
		sList.add(new Statement(8000L,4,"}"));
		sList.add(new Statement(9000L,3,"} else {"));
		sList.add(new Statement(10000L,4,"return {"));
		sList.add(new Statement(11000L,5,"'background-color': '#e8ebd0'"));
		sList.add(new Statement(12000L,4,"}"));
		sList.add(new Statement(13000L,3,"}"));
		sList.add(new Statement(14000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateSelectedHighlightMethodStatements(String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"selectedHighlight"+indexSuffix+"({ row, rowIndex }) {"));
		sList.add(new Statement(5000L,1,"if (this.selectRows"+indexSuffix+".includes(rowIndex)) {"));
		sList.add(new Statement(6000L,2,"return {"));
		sList.add(new Statement(7000L,3,"'background-color': '#a1c3c0'"));
		sList.add(new Statement(8000L,2,"}"));
		sList.add(new Statement(9000L,1,"} else {"));
		sList.add(new Statement(10000L,2,"return {"));
		sList.add(new Statement(11000L,3,"'background-color': '#e8ebd0'"));
		sList.add(new Statement(12000L,2,"}"));
		sList.add(new Statement(13000L,1,"}"));
		sList.add(new Statement(14000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleCloseMethodStatements(String language) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handleClose(done) {"));
		if ("english".equalsIgnoreCase(language)) {
			sList.add(new Statement(2000L,3,"this.$confirm('Confirm close?')"));
		}else{
			sList.add(new Statement(2000L,3,"this.$confirm('确认关闭？')"));
		}
		sList.add(new Statement(3000L,4,".then(_ => {"));
		sList.add(new Statement(4000L,5,"done()"));
		sList.add(new Statement(5000L,4,"})"));
		sList.add(new Statement(6000L,4,".catch(_ => {})"));
		sList.add(new Statement(7000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowAddDialogMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"showAddDialog() {"));
		sList.add(new Statement(3000L,3,"this.form = {}"));
		sList.add(new Statement(4000L,3,"this.addDialogVisible = true"));
		sList.add(new Statement(5000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowAddDialogMethodStatements(String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"showAddDialog"+indexSuffix+"() {"));
		sList.add(new Statement(3000L,3,"this.form"+indexSuffix+" = {}"));
		sList.add(new Statement(4000L,3,"this.addDialogVisible"+indexSuffix+" = true"));
		sList.add(new Statement(5000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowViewDialogMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"showViewDialog() {"));
		sList.add(new Statement(3000L,3,"this.form = this.selectList[0]"));
		sList.add(new Statement(4000L,3,"this.viewDialogVisible = true"));
		sList.add(new Statement(5000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowViewDialogMethodStatements(String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"showViewDialog"+indexSuffix+"() {"));
		sList.add(new Statement(3000L,3,"this.form"+indexSuffix+" = this.selectList"+indexSuffix+"[0]"));
		sList.add(new Statement(4000L,3,"this.viewDialogVisible"+indexSuffix+" = true"));
		sList.add(new Statement(5000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowEditDialogMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"showEditDialog() {"));
		sList.add(new Statement(3000L,3,"this.form = this.selectList[0]"));
		sList.add(new Statement(4000L,3,"this.editDialogVisible = true"));
		sList.add(new Statement(5000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowEditDialogMethodStatements(String indexSuffix) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"showEditDialog"+indexSuffix+"() {"));
		sList.add(new Statement(3000L,1,"this.form"+indexSuffix+" = this.selectList"+indexSuffix+"[0]"));
		sList.add(new Statement(4000L,1,"this.editDialogVisible"+indexSuffix+" = true"));
		sList.add(new Statement(5000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateShowChangePasswordDialogMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"showChangePasswordDialog() {"));
		sList.add(new Statement(3000L,1,"this.form = this.selectList[0]"));
		sList.add(new Statement(4000L,1,"this.changePasswordDialogVisible = true"));
		sList.add(new Statement(5000L,0,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateTranslateDomainMethodStatements(FrontDomain domain) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,1,"translate"+domain.getCapFirstDomainName()+"("+domain.getLowerFirstDomainName()+"Id) {"));
		sList.add(new Statement(2000L,2,"for (var i = 0; i < this.active"+domain.getCapFirstPlural()+".length; i++) {"));
		sList.add(new Statement(3000L,3,"if (this.active"+domain.getCapFirstPlural()+"[i]."+domain.getDomainId().getLowerFirstFieldName()+" === "+domain.getLowerFirstDomainName()+"Id) {"));
		sList.add(new Statement(4000L,4,"this."+domain.getLowerFirstDomainName()+" = this.active"+domain.getCapFirstPlural()+"[i]"));
		sList.add(new Statement(5000L,4,"return"));
		sList.add(new Statement(6000L,3,"}"));
		sList.add(new Statement(7000L,2,"}"));
		sList.add(new Statement(8000L,2,"this."+domain.getLowerFirstDomainName()+" = {}"));
		sList.add(new Statement(9000L,1,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateHandleImageSuccessMethodStatements(FrontDomain domain,FrontField field) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"handle"+domain.getCapFirstDomainName()+field.getCapFirstFieldName()+"ImageSuccess(res, "+field.getLowerFirstFieldName()+"File) {"));
		sList.add(new Statement(2000L,3,"this."+field.getLowerFirstFieldName()+"ImageUrl = URL.createObjectURL("+field.getLowerFirstFieldName()+"File.raw)"));
		sList.add(new Statement(3000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateBeforeImageUploadsMethodStatements(FrontDomain domain,FrontField field) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"before"+domain.getCapFirstDomainName()+field.getCapFirstFieldName()+"ImageUpload("+field.getLowerFirstFieldName()+"File) {"));
		sList.add(new Statement(2000L,3,"this."+field.getLowerFirstFieldName()+"File = "+field.getLowerFirstFieldName()+"File"));
		sList.add(new Statement(3000L,3,"console.log(this."+field.getLowerFirstFieldName()+"File)"));
		sList.add(new Statement(4000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateUpImageDataMethodStatements(FrontDomain domain,FrontField field) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"up"+domain.getCapFirstDomainName()+field.getCapFirstFieldName()+"ImageData() {"));
		sList.add(new Statement(2000L,3,"let formData = new FormData()"));
		sList.add(new Statement(3000L,3,"formData.append('head', this."+field.getLowerFirstFieldName()+"File)"));
		sList.add(new Statement(4000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateToQueryStringMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"toQueryString(obj) {"));
		sList.add(new Statement(2000L,3,"var ary = []"));
		sList.add(new Statement(3000L,3,"var str"));
		sList.add(new Statement(4000L,3,"for (var i in obj) {"));
		sList.add(new Statement(5000L,4,"ary.push(i)"));
		sList.add(new Statement(6000L,4,"ary.push(`=${obj[i]}&`)"));
		sList.add(new Statement(7000L,3,"}"));
		sList.add(new Statement(8000L,3,"str = ary.join('')"));
		sList.add(new Statement(9000L,3,"str = str.slice(0, str.length - 1)"));
		sList.add(new Statement(10000L,3,"return str"));
		sList.add(new Statement(11000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateSearchFilterFunMethodStatements(FrontDomain domain,boolean isExcel,boolean isPDF,boolean isWord,boolean isPPT) {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"searchFilterFun(command) {"));
		if (isExcel) sList.add(new Statement(2000L,3,"if (command === 'Excel') this.filter"+domain.getCapFirstPlural()+"Excel()"));
		if (isPDF) sList.add(new Statement(3000L,3,"if (command === 'PDF') this.filter"+domain.getCapFirstPlural()+"PDF()"));
		if (isWord) sList.add(new Statement(4000L,3,"if (command === 'Word') this.filter"+domain.getCapFirstPlural()+"Word()"));
		if (isPPT) sList.add(new Statement(5000L,3,"if (command === 'PPT') this.filterPPT"+domain.getCapFirstPlural()+"()"));
		sList.add(new Statement(6000L,2,"},"));
		return WriteableUtil.merge(sList);
	}

	public static StatementList generateParseBooleanMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"parseBoolean(val) {"));
		sList.add(new Statement(2000L,3,"if (val === undefined || val === null || val === '') return false"));
		sList.add(new Statement(3000L,3,"var isInt = /^(-}+)?\\d+$/.test(val)"));
		sList.add(new Statement(4000L,3,"if (isInt && val === '0') return false"));
		sList.add(new Statement(5000L,3,"else if (isInt && val === '1') return true"));
		sList.add(new Statement(6000L,3,"else if (val.toString().toLowerCase() === 'false') return false"));
		sList.add(new Statement(7000L,3,"else if (val.toString().toLowerCase() === 'true') return true"));
		sList.add(new Statement(8000L,3,"else if (val.toString().toLowerCase() === 'f') return false"));
		sList.add(new Statement(9000L,3,"else if (val.toString().toLowerCase() === 't') return true"));
		sList.add(new Statement(10000L,3,"else if (val.toString().toLowerCase() === 'n') return false"));
		sList.add(new Statement(11000L,3,"else if (val.toString().toLowerCase() === 'y') return true"));
		sList.add(new Statement(12000L,3,"else if (val.toString().toLowerCase() === 'no') return false"));
		sList.add(new Statement(13000L,3,"else if (val.toString().toLowerCase() === 'yes') return true"));
		sList.add(new Statement(14000L,3,"else return false"));
		sList.add(new Statement(15000L,2,"},"));

		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateParseBooleanIntMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"parseBooleanInt(val) {"));
		sList.add(new Statement(2000L,3,"if (val === undefined || val === null || val === '') return 0"));
		sList.add(new Statement(3000L,3,"var isInt = /^(-}+)?\\d+$/.test(val)"));
		sList.add(new Statement(4000L,3,"if (isInt && val === '0') return 0"));
		sList.add(new Statement(5000L,3,"else if (isInt && val === '1') return 1"));
		sList.add(new Statement(6000L,3,"else if (val.toString().toLowerCase() === 'false') return 0"));
		sList.add(new Statement(7000L,3,"else if (val.toString().toLowerCase() === 'true') return 1"));
		sList.add(new Statement(8000L,3,"else if (val.toString().toLowerCase() === 'f') return 0"));
		sList.add(new Statement(9000L,3,"else if (val.toString().toLowerCase() === 't') return 1"));
		sList.add(new Statement(10000L,3,"else if (val.toString().toLowerCase() === 'n') return 0"));
		sList.add(new Statement(11000L,3,"else if (val.toString().toLowerCase() === 'y') return 1"));
		sList.add(new Statement(12000L,3,"else if (val.toString().toLowerCase() === 'no') return 0"));
		sList.add(new Statement(13000L,3,"else if (val.toString().toLowerCase() === 'yes') return 1"));
		sList.add(new Statement(14000L,3,"else return 0"));
		sList.add(new Statement(15000L,2,"},"));

		return WriteableUtil.merge(sList);
	}
	
	public static StatementList generateParseIntNegMethodStatements() {
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,2,"parseIntNeg(val) {"));
		sList.add(new Statement(2000L,3,"if (isBlank(val) || parseInt(val) <= 0) return -1"));
		sList.add(new Statement(3000L,3,"else return parseInt(val)"));
		sList.add(new Statement(15000L,2,"},"));
		return WriteableUtil.merge(sList);
	}
}


